package com.freshcity.manager.support
{
	import com.freshcity.graphics.MessageBack;
	import com.greensock.TimelineLite;
	import com.greensock.TweenLite;
	import com.greensock.easing.Strong;
	import com.pblabs.debug.Logger;
	
	import flash.display.Sprite;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import flash.text.TextFormat;

	public class RollTipsItem extends Sprite
	{
		private var _back:MessageBack;
		private var _textField:TextField;
		private var _endCall:Function;
		
		public function RollTipsItem()
		{
			this.initUI();
		}
		
		private function initUI():void
		{
			mouseEnabled = false;
			mouseChildren = false;
			this._back = new MessageBack();
			this._textField = new TextField();
			var tf:TextFormat = new TextFormat("宋体",12,0xffffff);
			tf.leading = 5;
			
			this._textField.autoSize = TextFieldAutoSize.CENTER;
			this._textField.defaultTextFormat = tf;
			//this._textField.multiline = true;
			//this._textField.wordWrap = true;
			
			
			addChild(this._back);
			addChild(this._textField);
		}
		
		public function updateData(arg1:String, arg2:Function):void
		{
			this._endCall = arg2;
			//this._textField.width = PBE.mainStage.stageWidth / 2 - 120;
			this._textField.text = arg1;
			this._back.width = this._textField.width + 10;
			this._back.height = this._textField.height + 6;
			
			this._textField.x = 5;
			this._textField.y = 3;			
			
			//Logger.debug(this,"width:".concat(_textField.width),"height:".concat(_textField.height));
			
			//this._textField.y = 100;
			TweenLite.from(this, 0.5, {alpha:0,y:"+10"});
			TweenLite.to(this, 0.5, {onComplete:onInEnd,alpha:0,y:"-10",delay:1.5});
		}
		
		private function onInEnd():void
		{
			if (this._endCall != null) 
			{
				this._endCall.call(this, this);
			}
		}
		
		public function dispose():void
		{
			this._textField.text = "";
			this._textField.y = 0;
			this._textField.alpha = 1;
			this.y=0;
			this.x=0;
			this.alpha = 1;
			this._endCall = null;
		}
		
	}
}